<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex align-stretch benben-position-layout flex platformAnnouncement_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub platformAnnouncement_fd0_0'>
          <view class='flex align-center platformAnnouncement_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  platformAnnouncement_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex align-center'>
            <text class='platformAnnouncement_fd0_0_c1_c0'>平台消息</text>
          </view>
          <view class='flex align-center platformAnnouncement_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---平台消息flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch justify-center benben-flex-layout">
        <view class='flex flex-direction flex-wrap align-stretch platformAnnouncement_fd1_0'
         @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/meaasge/messageDetail/messageDetail?aid=${item.aid}`"
         v-for="(item,index) in homeList" :key="index">
          <text class='platformAnnouncement_fd1_0_c0'>{{item.title}}</text>
          <text class='platformAnnouncement_fd1_0_c1'>{{item.brief}}</text>
          <image class='platformAnnouncement_fd1_0_c2' mode="aspectFill" :src='item.thumb'
          v-if="item.thumb"></image>
          <view class='flex flex-wrap align-center platformAnnouncement_fd1_0_c3' style="margin-left: 6rpx;">
            <text class='platformAnnouncement_fd1_0_c3_c0'>{{item.create_time}}</text>
          </view>
        </view>
      </view>
      <u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status" :icon-type="iconType"
        :load-text="loadText" />
      <!---平台消息flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "page": 1,
        "is_pull": true,
        "last_page": 1,
        "status": 'loadmore',
        "iconType": 'flower',
        "loadText": {
          loadmore: '轻轻上拉',
          loading: '努力加载中',
          nomore: '我也是有底线的'
        },
        homeList: [],
        userId:''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      if(uni.getStorageSync('USER_INFO')){
        let user =uni.getStorageSync('USER_INFO')
        this.userId=user.id
        console.log(this.userId,'用户id')
      }else{
        console.log('用户未登录')
      }
      this.getListFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    // 上拉加载
    onReachBottom() {
      if (this.page >= this.last_page) return;
      this.status = 'loading';
      this.page++;
      setTimeout(() => {

        if (this.page >= this.last_page) this.status = 'nomore';
        else this.status = 'loading';
        this.is_pull = false;
        this.getListFunc();
      }, 500)
    },
    onPageScroll(e) {

    },
    methods: {
      //查询列表
      async getListFunc() {
        uni.showLoading({

        })
        let res = await this.$api.post(global.apiUrls.post65222991aec37, {
          page: this.page,
          user_id:this.userId
        });
        uni.stopPullDownRefresh();
        if (res.data.code == 1) {
          this.last_page = res.data.data.last_page;
          console.log(this.last_page, 'this.last_page')
          if (this.is_pull) {
            this.homeList = res.data.data.data;
            uni.hideLoading()
            console.log(this.homeList, 'this.homeList')
          } else {
            this.homeList = this.homeList.concat(res.data.data.data);
            uni.hideLoading()
          }
        } else {
          this.$message.info(res.data.msg);
        }
      },
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .platformAnnouncement_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .platformAnnouncement_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .platformAnnouncement_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
  }

  .platformAnnouncement_fd0_0_c0 {
    width: 180rpx;
  }

  .platformAnnouncement_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .platformAnnouncement_fd1_1 {
    background: #fff;
    margin: 0rpx 24rpx 24rpx 24rpx;
    padding: 24rpx 24rpx 24rpx 24rpx;
    background-size: 100% auto !important;
  }

  .platformAnnouncement_fd1_0_c3_c0 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 33rpx;
  }

  .platformAnnouncement_fd1_0_c3 {
    border-top: 1px solid rgba(238, 238, 238, 1);
    padding: 24rpx 0rpx 0rpx 0rpx;
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .platformAnnouncement_fd1_0_c2 {
    width: 638rpx;
    height: 298rpx;
    border-radius: 16rpx;
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .platformAnnouncement_fd1_0_c1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
    line-height: 46rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #666666;
    -webkit-line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .platformAnnouncement_fd1_0_c0 {
    line-height: 36rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .platformAnnouncement_fd1_0 {
    background: #fff;
    margin: 25rpx 24rpx 24rpx 24rpx;
    padding: 24rpx 24rpx 24rpx 24rpx;
    background-size: 100% auto !important;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }
</style>